#ifndef MY_NODO
#define MY_NODO

#include "../tinyxml.h"
#include <map>
#include <string>
#include <vector>
#include <iostream>
#include <GL\glui.h>
#include "View.h"
#include "Transformation.h"
#include "Material.h"
#include "Light.h"
#include "Illumination.h"
#include "Nodo.h"

using namespace std;


class Nodo
{
protected:
	vector<Nodo*> sons;
	vector<string> sons_string;
	int active_material;
public:
	string id;
	static float texture_s, texture_t;
	pair<int,pair<float,float>>* node_texture;
	Transformation *transf;
	vector<Material*> materials;
	

	Nodo () {active_material=0;node_texture= new pair<int,pair<float,float>>;};
	void add_son(Nodo* son){sons.push_back(son);};
	void add_son_id(string id){sons_string.push_back(id);};
	vector<string> getSons(){return sons_string;};
	virtual void draw() = 0;
	virtual Nodo* clone() = 0;
	string getID() {return id;};
	void setId(string id);
	void setTransformation(Transformation* t){transf=t;};
	void changeMat(){active_material++;if(active_material>=materials.size()) active_material=0;};
};

class Component : public Nodo
{
private:
public:
	Component(){};
	void draw();
	void read(){};
	Nodo* clone(){return new Component(*this);};
};

class Shape : public Nodo
{
private:
public:
	Shape(){};
	virtual void draw() = 0;
	virtual Nodo* clone() = 0;
}; 

class Triangle: public Shape
{
private:
	float x1,x2,x3,y1,y2,y3,z1,z2,z3;
public:
	Triangle(){};
	int read(TiXmlElement *shape);
	Nodo* clone() { return new Triangle(*this); }
	void draw();
};

class Rectangle: public Shape
{
private:
	float x1,y1,x2,y2;
public:
	Rectangle(){};
	int read(TiXmlElement *shape);
	Nodo* clone() { return new Rectangle(*this); }
	void draw();
};

class Cylinder: public Shape
{
private:
	float base, top, height;
	int slices, stacks;
public:
	Cylinder(){};
	int read(TiXmlElement *shape);
	Nodo* clone() { return new Cylinder(*this); }
	void draw();
};

class Sphere: public Shape
{
private:
	float radius;
	int slices, stacks;
public:
	Sphere(){};
	int read(TiXmlElement *shape);
	Nodo* clone() { return new Sphere(*this); }
	void draw();
};

class Torus: public Shape
{
private:
	float inner,outer;
	int slices,loops;
public:
	Torus(){};
	int read(TiXmlElement *shape);
	Nodo* clone() { return new Torus(*this); }
	void draw();
};

#endif